Am I missing something, or is the only way to create triggers is by a DXL script? If that's the case, ok. But I can't find documentation of any other way to create a trigger. There also doesn't seem to be any way of managing persistent triggers. You'd think there'd be an option from one of the drop down menus on a module that told you what triggers were attached to the current module. Do I have to write a script to do my own trigger management as well?
|
Re: Triggers
...Am I missing something... - No
Module m
Trigger t = null
Item i
string itemType
string modName, fullModName
for i in current Project do
{
itemType = type i
if( itemType == "Formal")
{
fullModName = fullName(i)
modName = name(i)
m = read(fullModName,false)
for t in m do {
print path(i) "/" modName " : " name t "\n"
}
close(m)
}
}
Paul Miller
|
Re: Triggers |
Re: Triggers homer_3 - Mon Feb 07 01:34:21 EST 2011 Regards, Peter |
Re: Triggers Peter_Albert - Mon Feb 07 03:38:38 EST 2011 Can somebody please tell me why attaching files never works for me? Here is the code
// Show / delete all triggers
/*
This script display a simple dialogue box with information about
dynamic and persistent triggers in the current module, project and database
"List triggers" : Re-create the list of triggers
"Delete triggers": Button: For each trigger found, displays a
Yes/No/Cancel dialogue for trigger deletion
"Delete triggers": Text field: Copy / paste the name of one trigger and hit
<Return> to delete this trigger
*/
DB baseDB
DBE infoDBE
const int TEXT_WIDTH = 200
const int TEXT_HEIGHT = 300
const int FIELD_WIDTH = 20
Buffer disp = create
Skip triggerList = createString()
DBE deleteDBE = null
const string options[] = {"Yes", "No", "Cancel"}
// ----------------------------------------------------------------------
void triggerInfo(Trigger t, bool deleteIt, &exitLoop)
{
if (null t){disp += "\n null trigger!\n"; return}
if (kind(t) == "builtin"){return}
if (!put(triggerList, name(t) "", t)){return}
disp += "\n"
disp += "Name: " name(t) "\n"
disp += "Kind: " kind(t) "\n"
disp += "DXL: " dxl(t) "\n"
disp += "Level: " stringOf(level(t)) "\n"
disp += "Type: " stringOf(type(t)) "\n"
disp += "Event: " stringOf(event(t)) "\n"
disp += "Stored in: " stored(t) "\n"
Module m = module t
int queryResult
if (!null m){disp += "Module: " fullName(m) "\n"}
if (deleteIt)
{
queryResult = query("Delete Trigger " (name t) "?", options)
if (queryResult == 0)
{
string del = delete(t)
disp += "Deleted: " del "\n"
}
else if (queryResult == 2){exitLoop = true}
}
}
// ----------------------------------------------------------------------
void triggerList(bool deleteIt)
{
bool exitLoop = false
delete triggerList; triggerList = createString()
Trigger t
disp = "{\\b Module}"
Module m = current
if (!null m)
{
disp += ": " name(m) ""
for t in m do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)
}
}
else {disp += ": no current module"}
disp += "\n\n{\\b Project}"
Project p = current
if (!null p){for t in p do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)}
}
else {disp += ": no current project"}
disp += "{\n\n\\b Database}"
for t in database do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)
}
set(infoDBE, stringOf(disp))
}
// ----------------------------------------------------------------------
void listTriggers(DB db){triggerList(false)}
// ----------------------------------------------------------------------
void deleteTriggers(DB db){triggerList(true); triggerList(false)}
// ----------------------------------------------------------------------
void deleteTrigger(DBE dbe)
{
string selectedTrigger = get(deleteDBE)
Trigger t
string del
if (find(triggerList, selectedTrigger, t))
{
del = delete(t)
if (!null del){ack "Error deleting trigger:\n\n" del ""}
else {set(deleteDBE, ""); triggerList(false)}
}
else {set(deleteDBE, "No such trigger (" selectedTrigger ")")}
}
// ----------------------------------------------------------------------
void displayHelp(DB db)
{
Buffer disp = create
disp = "{\\b Trigger list}\n\n"
disp += "{\\b List triggers}: "
disp += "List all triggers in module, project and database\n"
disp += "{\\b Delete triggers} (button): "
disp += "Delete all triggers in module, project and database\n"
disp += "{\\b Delete trigger} (field): "
disp += "Delete one trigger: "
disp += "type (copy/paste) trigger name and hit <return> "
set(infoDBE, stringOf(disp))
delete disp
}
// ----------------------------------------------------------------------
void closeDB(DB db)
{delete disp; delete triggerList; hide db; destroy db; db = null}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Create DB
baseDB = create("Trigger info / deletion")
infoDBE = richText(baseDB, "", "", TEXT_WIDTH, TEXT_HEIGHT, true)
deleteDBE = field(baseDB, "Delete trigger", "", FIELD_WIDTH, false)
set(deleteDBE, deleteTrigger)
apply(baseDB, "List triggers", listTriggers)
apply(baseDB, "Delete triggers", deleteTriggers)
apply(baseDB, "Help", displayHelp)
close(baseDB, true, closeDB)
realize(baseDB)
setExtraHeightShare(infoDBE, 1.0)
triggerList(false)
show(baseDB)
|
Re: Triggers http://galactic-solutions.com/GalacticDownloadsMain.htm Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Triggers Peter_Albert - Mon Feb 07 03:42:21 EST 2011 Can somebody please tell me why attaching files never works for me? Here is the code
// Show / delete all triggers
/*
This script display a simple dialogue box with information about
dynamic and persistent triggers in the current module, project and database
"List triggers" : Re-create the list of triggers
"Delete triggers": Button: For each trigger found, displays a
Yes/No/Cancel dialogue for trigger deletion
"Delete triggers": Text field: Copy / paste the name of one trigger and hit
<Return> to delete this trigger
*/
DB baseDB
DBE infoDBE
const int TEXT_WIDTH = 200
const int TEXT_HEIGHT = 300
const int FIELD_WIDTH = 20
Buffer disp = create
Skip triggerList = createString()
DBE deleteDBE = null
const string options[] = {"Yes", "No", "Cancel"}
// ----------------------------------------------------------------------
void triggerInfo(Trigger t, bool deleteIt, &exitLoop)
{
if (null t){disp += "\n null trigger!\n"; return}
if (kind(t) == "builtin"){return}
if (!put(triggerList, name(t) "", t)){return}
disp += "\n"
disp += "Name: " name(t) "\n"
disp += "Kind: " kind(t) "\n"
disp += "DXL: " dxl(t) "\n"
disp += "Level: " stringOf(level(t)) "\n"
disp += "Type: " stringOf(type(t)) "\n"
disp += "Event: " stringOf(event(t)) "\n"
disp += "Stored in: " stored(t) "\n"
Module m = module t
int queryResult
if (!null m){disp += "Module: " fullName(m) "\n"}
if (deleteIt)
{
queryResult = query("Delete Trigger " (name t) "?", options)
if (queryResult == 0)
{
string del = delete(t)
disp += "Deleted: " del "\n"
}
else if (queryResult == 2){exitLoop = true}
}
}
// ----------------------------------------------------------------------
void triggerList(bool deleteIt)
{
bool exitLoop = false
delete triggerList; triggerList = createString()
Trigger t
disp = "{\\b Module}"
Module m = current
if (!null m)
{
disp += ": " name(m) ""
for t in m do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)
}
}
else {disp += ": no current module"}
disp += "\n\n{\\b Project}"
Project p = current
if (!null p){for t in p do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)}
}
else {disp += ": no current project"}
disp += "{\n\n\\b Database}"
for t in database do
{
if (exitLoop){continue}
triggerInfo(t, deleteIt, exitLoop)
}
set(infoDBE, stringOf(disp))
}
// ----------------------------------------------------------------------
void listTriggers(DB db){triggerList(false)}
// ----------------------------------------------------------------------
void deleteTriggers(DB db){triggerList(true); triggerList(false)}
// ----------------------------------------------------------------------
void deleteTrigger(DBE dbe)
{
string selectedTrigger = get(deleteDBE)
Trigger t
string del
if (find(triggerList, selectedTrigger, t))
{
del = delete(t)
if (!null del){ack "Error deleting trigger:\n\n" del ""}
else {set(deleteDBE, ""); triggerList(false)}
}
else {set(deleteDBE, "No such trigger (" selectedTrigger ")")}
}
// ----------------------------------------------------------------------
void displayHelp(DB db)
{
Buffer disp = create
disp = "{\\b Trigger list}\n\n"
disp += "{\\b List triggers}: "
disp += "List all triggers in module, project and database\n"
disp += "{\\b Delete triggers} (button): "
disp += "Delete all triggers in module, project and database\n"
disp += "{\\b Delete trigger} (field): "
disp += "Delete one trigger: "
disp += "type (copy/paste) trigger name and hit <return> "
set(infoDBE, stringOf(disp))
delete disp
}
// ----------------------------------------------------------------------
void closeDB(DB db)
{delete disp; delete triggerList; hide db; destroy db; db = null}
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Create DB
baseDB = create("Trigger info / deletion")
infoDBE = richText(baseDB, "", "", TEXT_WIDTH, TEXT_HEIGHT, true)
deleteDBE = field(baseDB, "Delete trigger", "", FIELD_WIDTH, false)
set(deleteDBE, deleteTrigger)
apply(baseDB, "List triggers", listTriggers)
apply(baseDB, "Delete triggers", deleteTriggers)
apply(baseDB, "Help", displayHelp)
close(baseDB, true, closeDB)
realize(baseDB)
setExtraHeightShare(infoDBE, 1.0)
triggerList(false)
show(baseDB)
for trg in module do { if I care about this trigger then trgStore = trg } deal with trgStore trgStore ends up with the value of the LAST trigger in the module, if any were found. It could work if you added a break after the assignment, but then you don't check other triggers. Thus, my "delete" trigger script just looks for them and pauses, with a modal dialog box, the option to delete THIS one, user can cancel the script, but yes or no results in finding and displaying the next trigger. Knowing what I know now I could code around that, but its awkward.
|
Re: Triggers Your deploy trigger script should have a machanism for removing the trigger, which you need to do before deploying it anyway: if (confirm("Delete trigger " Name "??")) delete (Name, module->attribute,pre, save, 5) if (confirm("Deploy trigger " Name "??")) trigger(Name, module->attribute,pre, save, 5, DXL)
|
Re: Triggers |
Re: Triggers homer_3 - Mon Feb 07 14:27:01 EST 2011 Trigger trigger(string name, l, t, e, int p, string dxl)
Paul Miller
|
Re: Triggers SystemAdmin - Mon Feb 07 15:28:19 EST 2011 Trigger trigger(string name, l, t, e, int p, string dxl)
Paul Miller
That's what I thought, until I tried
string s = open
trigger("foo", object, post, s, 1, dxlCode)
trigger("foo", object, post, open, 1, dxlCode)
|
Re: Triggers homer_3 - Mon Feb 07 16:19:18 EST 2011
That's what I thought, until I tried
string s = open
trigger("foo", object, post, s, 1, dxlCode)
trigger("foo", object, post, open, 1, dxlCode)
No edit? This fails with invalid return type as well.
string foo(){
return open
}
trigger("foo", object, post, "", 1, dxlCode)
|
Re: Triggers homer_3 - Mon Feb 07 16:19:18 EST 2011
That's what I thought, until I tried
string s = open
trigger("foo", object, post, s, 1, dxlCode)
trigger("foo", object, post, open, 1, dxlCode)
I've only ever used the trigger string constants for 'l', 't' and 'e'. Whilst the theory would suggest that a string variable should work, I'm assuming that DXL may have type cast 'l', 't' and 'e' so that they will only work with the string constants - but I'm only guessing.
string s = open
trigger("foo", object, post, s, 1, dxlCode)
Paul Miller
|
Re: Triggers SystemAdmin - Mon Feb 07 17:21:31 EST 2011
I've only ever used the trigger string constants for 'l', 't' and 'e'. Whilst the theory would suggest that a string variable should work, I'm assuming that DXL may have type cast 'l', 't' and 'e' so that they will only work with the string constants - but I'm only guessing.
string s = open
trigger("foo", object, post, s, 1, dxlCode)
Paul Miller
Yea, that 1st line was more psuedocode. I set s to open using a skip list. Is there a reason why you would not want to use the trigger string constants as they are?
|
Re: Triggers homer_3 - Mon Feb 07 14:27:01 EST 2011
|
Re: Triggers llandale - Mon Feb 07 20:56:28 EST 2011
|
Re: Triggers homer_3 - Tue Feb 08 15:12:30 EST 2011 Why not? Without trying the following should work fine, regards, Mathias trigType_ type = pre type = post trigEvent_ event = save trigEvent_ event = close // etc...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Triggers Mathias Mamsch - Tue Feb 08 15:23:08 EST 2011 Why not? Without trying the following should work fine, regards, Mathias trigType_ type = pre type = post trigEvent_ event = save trigEvent_ event = close // etc...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Mathias - excellent - gave it a try and it worked (code used is shown below) - I'm interested to know more about how this works. From my simple understanding, 'l', 't' and 'e' are declared as string types and it seems that you cannot substitute these with a string variable and must use pre defined string constants, so how does your substitution of trigEvent_ & trigType_ manage to work?
Trigger TestTrig
string DXLTrig = "ack \"A message when the module opens\""
trigEvent_ event = open
trigType_ type = pre
TestTrig = trigger("triggertest", module, type, event, 10, DXLTrig)
Paul Miller
|
Re: Triggers Mathias Mamsch - Tue Feb 08 15:23:08 EST 2011 Why not? Without trying the following should work fine, regards, Mathias trigType_ type = pre type = post trigEvent_ event = save trigEvent_ event = close // etc...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Triggers homer_3 - Tue Feb 08 17:45:37 EST 2011 They are not in the DXL manual, and in fact there are loads of so-called 'internal' data types not advertised there. There is a lot of good things to be gleaned out of the doors.exe file. Here are the trigger data types:
struct Trigger {};
struct trigLevel_ {};
struct trigLevelMod_ {};
struct trigLevelDesc_ {};
struct trigType_ {} ;
struct trigEvent_ {} ;
struct TriggerStatus {};
|
Re: Triggers SystemAdmin - Tue Feb 08 17:30:50 EST 2011
Mathias - excellent - gave it a try and it worked (code used is shown below) - I'm interested to know more about how this works. From my simple understanding, 'l', 't' and 'e' are declared as string types and it seems that you cannot substitute these with a string variable and must use pre defined string constants, so how does your substitution of trigEvent_ & trigType_ manage to work?
Trigger TestTrig
string DXLTrig = "ack \"A message when the module opens\""
trigEvent_ event = open
trigType_ type = pre
TestTrig = trigger("triggertest", module, type, event, 10, DXLTrig)
Paul Miller
I guess I should upload the "undocumented perms" lists, should I? I will create a separate post for that. The principle behind this is pretty easy. You declare your own type and a few constants. Example:
struct RequirementType{}
const RequirementType Hardware = addr_ 0
const RequirementType Software = addr_ 1
const RequirementType Firmware = addr_ 2
string myFunction (RequirementType x) {
if (x == Hardware) return "Its a hardware Requirement!"
if (x == Software) return "Its a software Requirement!"
if (x == Firmware) return "Its a firmware Requirement!"
}
RequirementType myType = Hardware
print (myFunction myType) "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Triggers Mathias Mamsch - Wed Feb 09 15:19:43 EST 2011
I guess I should upload the "undocumented perms" lists, should I? I will create a separate post for that. The principle behind this is pretty easy. You declare your own type and a few constants. Example:
struct RequirementType{}
const RequirementType Hardware = addr_ 0
const RequirementType Software = addr_ 1
const RequirementType Firmware = addr_ 2
string myFunction (RequirementType x) {
if (x == Hardware) return "Its a hardware Requirement!"
if (x == Software) return "Its a software Requirement!"
if (x == Firmware) return "Its a firmware Requirement!"
}
RequirementType myType = Hardware
print (myFunction myType) "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hi, trigLevel_ tlevel = module->"MySRD"->attribute ->"Val_Correct"
trigLevel_ tlevel = module;
|
Re: Triggers SystemAdmin - Thu Dec 06 09:19:06 EST 2012
Hi, trigLevel_ tlevel = module->"MySRD"->attribute ->"Val_Correct"
trigLevel_ tlevel = module;
I conclude that if you are writing generic library functions to manage your triggers you will need to either..
-Louie Unfortunately, I wrote library functions using only trigLevel_ since I tested only with simple triggers. |
Re: Triggers llandale - Thu Dec 06 10:20:07 EST 2012
I conclude that if you are writing generic library functions to manage your triggers you will need to either..
-Louie Unfortunately, I wrote library functions using only trigLevel_ since I tested only with simple triggers.
Hi Louie, string tname = "MyTrigger"; string tlmod = "MyModule"; string tlattr = "MyAttribute"; trigLevelDesc_ tld = module->tlmod->attribute->tlattr; delete(tname, tld, post, save, 8); // This works t = trigger(tname, tld, post, save, 8, "infoBox(\"It works!\")"); //This gives an exception t = trigger(tname, module->tlmod->attribute->tlattr, post, save, 8, "infoBox(\"It works!\")"); //This works
|
Re: Triggers SystemAdmin - Tue Dec 11 03:04:20 EST 2012
Hi Louie, string tname = "MyTrigger"; string tlmod = "MyModule"; string tlattr = "MyAttribute"; trigLevelDesc_ tld = module->tlmod->attribute->tlattr; delete(tname, tld, post, save, 8); // This works t = trigger(tname, tld, post, save, 8, "infoBox(\"It works!\")"); //This gives an exception t = trigger(tname, module->tlmod->attribute->tlattr, post, save, 8, "infoBox(\"It works!\")"); //This works
-Louie |